package com.galeno.day05;

import com.galeno.FlinkUtils;
import org.apache.flink.api.java.functions.KeySelector;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.KeyedStream;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @author galeno
 * @Title:
 * @Description:
 * @date 2021/10/2022:18
 */
public class ProKeyDmeo {
    public static void main(String[] args) throws Exception {
        Configuration conf = new Configuration();
        conf.setInteger("rest.port",10086);
        StreamExecutionEnvironment locEnvWebUI = FlinkUtils.getLocEnvWebUI(conf);
        DataStreamSource<String> lines = locEnvWebUI.socketTextStream(FlinkUtils.LinuxURL, FlinkUtils.port);
        KeyedStream<String, String> keyedStream = lines.keyBy(new KeySelector<String, String>() {
            @Override
            public String getKey(String s) throws Exception {
                return s.toUpperCase();
            }
        });
        keyedStream.print();
        locEnvWebUI.execute();

    }
}
